// Decompiled by Jad v1.5.8f. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: packimports(3) 
// Source File Name:   ValidateUser.java

package org.fiel.login;

import java.util.*;
import org.fiel.commons.jdbc.Constraint;
import org.fiel.commons.jdbc.Finder;
import org.fiel.domain.User;
import org.fiel.persistence.UserPersistor;

// Referenced classes of package org.fiel.login:
//            FielPrincipal

public class ValidateUser
{

    public ValidateUser()
    {
    }

    public FielPrincipal checkCredentials(String user, String password)
    {
        FielPrincipal fielPrincipal = null;
        List constraintList = new ArrayList();
        Constraint constraint = null;
        User aUser = null;
        Finder userPersistor = new UserPersistor();
        constraint = new Constraint("userid", "=", user);
        constraintList.add(constraint);
        aUser = (User)userPersistor.FindByPK(constraintList);
        if(aUser == null)
            return null;
        if(aUser.getPassword().compareToIgnoreCase(password) == 0)
        {
            if(aUser.getFechaven() != null && aUser.getFechaven().compareTo(Calendar.getInstance().getTime()) <= 0)
                return null;
            fielPrincipal = new FielPrincipal();
            List ls = new ArrayList();
            ls.add(aUser.getNivel());
            fielPrincipal.setRoles(ls);
            fielPrincipal.setUsername(aUser.getId());
        }
        return fielPrincipal;
    }
}
